package servlet;

import  hadoop.hadooputil;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @auther 郭天凌
 * @date 2022/3/11
 */
@WebServlet("/demo")
public class servletdemo extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        // 获取参数
        String srcPath = req.getParameter("srcpath");
        String destPath = req.getParameter("destpath");

        System.out.println(srcPath);
        System.out.println(destPath);


        // hadoop 工具类
        hadooputil hadoop =   new hadooputil();
        String obj1 = hadoop.hadoopupload(srcPath,destPath);
        resp.setContentType("text/html;charset=utf-8");

        PrintWriter pw =  resp.getWriter();
        pw.write("<h1>"+ obj1);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);

    }
}
